import com.atshiyou.bean.Menu;
import com.atshiyou.bean.Role;
import com.atshiyou.bean.Student;
import com.atshiyou.dao.GradeDao;
import com.atshiyou.dao.RoleDao;
import com.atshiyou.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class TestRole {
    public static void main(String[] args) {
        SqlSession session = SqlSessionUtil.getSession();
        RoleDao roleDao = session.getMapper(RoleDao.class);
        Role byRoleId = roleDao.findByRoleId(5);
        if(byRoleId==null){
            System.out.println("无此角色ID");
            SqlSessionUtil.closeSession();
            return;
        }
        List<Menu> menuList = byRoleId.getMenuList();
        for (Menu menu : menuList) {
            System.out.println(menu+","+byRoleId.getRoleName());
        }

        System.out.println("================================");
        Menu byMenuId = roleDao.findByMenuId(28);
        List<Role> roleList = byMenuId.getRoleList();
        for (Role role : roleList) {
            System.out.println(role+","+byMenuId.getMenuName());

        }
        SqlSessionUtil.closeSession();
    }
}
